<% lineconst = 7%>
<% linenum = distlist.size/lineconst%>
<% leftnum = distlist.size%lineconst -%>
<table>
<% for i in 0...linenum
-%>
     <tr>
     <% for j in 0...lineconst
     dist_id = distlist[i*lineconst+j].id
     -%>
       <td>
       <div id="dist_<%= dist_id%>">
       <%= link_to_remote "#{distlist[i*lineconst+j].title}", :loading => "Element.hide('communities_div'),Element.show('loading-gif')", :complete => "Element.show('communities_div'), Element.hide('loading-gif'),Effect.Highlight('dist_#{dist_id}',{startcolor:'#ff99ff', endcolor:'#999999'})",:update=>"communities_div",:url => {:controller => "districts", :action => "ajaxsmallshowcomm", :id => distlist[i*lineconst+j] } %>
       </div>
       </td>
     <%
     end
     -%>
     </tr>
<%
   end
-%>
<% if leftnum > 0 -%>
  <tr>
  <% for i in 0...leftnum 
  dist_id = distlist[linenum*lineconst+i].id
  -%>
    <td>
    <div id="dist_<%= dist_id%>%>">
    <%= link_to_remote "#{distlist[linenum*lineconst+i].title}", :loading => "Element.hide('communities_div'),Element.show('loading-gif')", :complete => "Element.show('communities_div'), Element.hide('loading-gif'),Effect.Highlight('dist_#{dist_id}',{startcolor:'#ff99ff', endcolor:'#999999'})",:update=>"communities_div",:url => {:controller => "districts", :action => "ajaxshowcomm", :id => distlist[linenum*lineconst+i] } %>
    </div>
    </td>
  <% end -%>
  <% for i in 0...(lineconst-leftnum) -%>
    <td>
    &nbsp;
    </td>
  <% end -%>
  </tr>
<% end -%>
</table>
